%% Proteus_A_param - DSPBA Design Parameters Start
clc;
clear Proteus_A_param; 
Proteus_A_param.version = 10000;

%% System Parameters
Proteus_A_param.ChanCount   = 1;                    % How many data channels
Proteus_A_param.ClockRate   = 122.88000;            % The system clock rate in MHz
Proteus_A_param.SampleRate  = 30.72000;             % The data rate per channel in MSps (mega-samples per second)
Proteus_A_param.ClockMargin = 0.0;                  % Adjust the pipelining effort

%% Data Type Specification
Proteus_A_param.adc_word_length      = 16;         % Input data: bit width
Proteus_A_param.adc_fraction_length  = 15;         % Input data: fraction width
Proteus_A_param.dac_word_length      = 16;         % Input data: bit width
Proteus_A_param.dac_fraction_length  = 14;         % Input data: fraction width

Proteus_A_param.input_word_length      = 16;         % Input data: bit width
Proteus_A_param.input_fraction_length  = 15;         % Input data: fraction width
Proteus_A_param.output_word_length     = 18;         % Output data: bit width
Proteus_A_param.output_fraction_length = 17;         % Output data: fraction width

Proteus_A_param.output_word_length_FFT     = 16;         % Output data: bit width
Proteus_A_param.output_fraction_length_FFT = 14;         % Output data: fraction width
%% ModelIP setup
%% Filter 1
Proteus_A_param.filter1.SampleRate            = Proteus_A_param.SampleRate;  % Input rate at filter1
Proteus_A_param.filter1.FilterLength          = 64;                          % Number of Taps

Proteus_A_param.filter1.coeff_word_length     = 18;                          % filter1 coefficient: bit width
Proteus_A_param.filter1.coeff_fraction_length = 17;                          % filter1 coefficient: fraction width 

Proteus_A_param.filter_iir.coeff_word_length     = 18;                       % filter1 coefficient: bit width
Proteus_A_param.filter_iir.coeff_fraction_length = 16;                       % filter1 coefficient: fraction width 

Proteus_A_param.filter1.base_addr             = 512;                         % filter1 coefficient address map (start)

%Proteus_A_param.filter1.coeffs(1,:) = fi(fir1(Proteus_A_param.filter1.FilterLength-1,   0.1,      'DC-1' ),1,Proteus_A_param.filter1.coeff_word_length,Proteus_A_param.filter1.coeff_fraction_length); 
%Proteus_A_param.filter1.coeffs(2,:) = fi(fir1(Proteus_A_param.filter1.FilterLength-1,  [0.1 0.5], 'DC-0' ),1,Proteus_A_param.filter1.coeff_word_length,Proteus_A_param.filter1.coeff_fraction_length);
Proteus_A_param.filter1.prototype = fi(fir1(Proteus_A_param.filter1.FilterLength-1,0.15),1,Proteus_A_param.filter1.coeff_word_length,Proteus_A_param.filter1.coeff_fraction_length); 
Proteus_A_param.filter1.matrix = reshape(Proteus_A_param.filter1.prototype,4,Proteus_A_param.filter1.FilterLength/4);
Proteus_A_param.filter1.coeffs_p1 = Proteus_A_param.filter1.matrix(1,:);
Proteus_A_param.filter1.coeffs_p2 = Proteus_A_param.filter1.matrix(2,:);
Proteus_A_param.filter1.coeffs_p3 = Proteus_A_param.filter1.matrix(3,:);
Proteus_A_param.filter1.coeffs_p4 = Proteus_A_param.filter1.matrix(4,:);

%% Simulation Parameters

%Proteus_A_param.SampleTime  = 1;                   % One unit in Simulink simulation is one clock cycle 
% Proteus_A_param.SampleTime  = 1/(Proteus_A_param.SampleRate*1e6);                 
                                                    % One unit in Simulink simulation is one clock cycle 
Proteus_A_param.SampleTime_SlowRate = 1/(Proteus_A_param.SampleRate*1e6);                 
                                                    % One unit in Simulink
                                                    % simulation is one clock cycle                                                     
Proteus_A_param.SampleTime_FastRate = Proteus_A_param.SampleTime_SlowRate/(Proteus_A_param.ClockRate/Proteus_A_param.SampleRate);                 
                                                    % One unit in Simulink
                                                    % simulation is one clock cycle                                                     
Proteus_A_param.SampleTime  = Proteus_A_param.SampleTime_SlowRate;                 
                                                    % One unit in Simulink simulation is one clock cycle 
                                                    
Proteus_A_param.endTime     = 100000*Proteus_A_param.SampleTime; 
                                                    % How many simulation clock cycles

%% Stimulus data setup
Proteus_A_param.inputdata=zeros(Proteus_A_param.ChanCount,Proteus_A_param.endTime+1);
for chan=1:Proteus_A_param.ChanCount
    Proteus_A_param.inputdata(chan,:) = sin((0:Proteus_A_param.endTime)*pi/10*chan)/chan;
end;

%% Derived Parameters 
Proteus_A_param.Period          = Proteus_A_param.ClockRate / Proteus_A_param.SampleRate;           % Clock cycles between consecutive data samples for a particular channel
Proteus_A_param.ChanWireCount   = ceil(Proteus_A_param.ChanCount/Proteus_A_param.Period);           % How many wires are needed to support the specified number of channels?
Proteus_A_param.ChanCycleCount  = ceil(Proteus_A_param.ChanCount/Proteus_A_param.ChanWireCount);    % Range of the channel signal
%% DSPBA Design Parameters End
